<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test 6</title>
</head>
<body onbeforeunload="leave()">
<script>
   function leave() {
    alert("离开吗？")
  }
    alert("离开吗？")
</script>
</body>
</html>
